package com.lsc.www.day09.hm;

public class s3 {

    public static void main(String[] args) {
        s3 s = new s3();
        System.out.println("100以内的素数:");

        int count = 0;
        for (int i = 2; i < 100; i++) {
            if (s.isPrimeNumber(i) == true) {
                System.out.print(i + " ");
                count++;

                if (count % 10 == 0) {
                    System.out.print("\n");
                }

            }
        }
    }

    public boolean isPrimeNumber(int number) {
        boolean flag = true;
        if (number <= 0) {
            throw new IllegalArgumentException("number是不合法的参数!");
        }

        for (int i = 2; i <= Math.sqrt(number); i++) {
            if (number % i == 0) {
                flag = false;
                break;
            }
        }
        return flag;
    }
}

